import React, { useReducer } from 'react'
function reducer(state, action) {
  switch (action.type) {
    case 'add':
      return {
        ...state,
        count: state.count + 1,
      }
  }
}
export default function Test() {
  const [state, dispatch] = useReducer(reducer, {
    count: 1,
    msg: 'hello',
    arr: [1, 2, 3],
  })
  return (
    <div>
      Test
      <p>{state.count}</p>
      <button
        onClick={() => {
          dispatch({ type: 'add' })
        }}
      >
        按钮
      </button>
    </div>
  )
}
